package com.example.basic.web.controller.binding;

import com.example.basic.core.result.Result;
import com.example.basic.core.result.ResultGenerator;
import com.example.basic.custom.Log;
import com.example.basic.web.model.binding.BindingInfo;
import com.example.basic.web.service.binding.BindingInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(value  = "绑定关系", tags = {"绑定关系"})
@RestController
@RequestMapping("/api/v1/byg/binding")
public class BindingInfoController {

    @Resource
    private BindingInfoService bindingInfoService;

    @Log(title = "绑定关系", description = "取消绑定")
    @ApiOperation(value = "取消绑定", notes = "取消绑定")
    @PostMapping("/cancel")
    public Result<Integer> cancel(@ApiParam(name = "remainsCode", value = "遗体信息编码") @RequestParam String remainsCode ) {
        return ResultGenerator.genSuccessResult(bindingInfoService.cancel(remainsCode));
    }

    @Log(title = "绑定关系", description = "更新绑定关系")
    @ApiOperation(value = "更新绑定关系", notes = "更新绑定关系")
    @PostMapping("/modify")
    public Result<BindingInfo> modify(@ApiParam(name = "bindingInfo", value = "绑定信息") @RequestBody BindingInfo bindingInfo ) {
        return ResultGenerator.genSuccessResult(bindingInfoService.modify(bindingInfo));
    }

}
